package com.puzzletest.bean;

import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

public class General {
	public static final String STATUS = "status";
	public static final String MESSAGE = "message";
	public static final String DATA = "data";
	public static final String LIST = "list";

	// status <0 错误
	private int status;
	private String message;

	public General() {

	}

	public General(JSONObject jsonObject) {
		fromJson(jsonObject);
	}

	public boolean isSucceed() {
		return status == 1;
	}

	private void fromJson(JSONObject jsonObject) {
		if (jsonObject == null) {
			status = -1;
			message = "";
		}

		try {
			setStatus(jsonObject.getInt(STATUS));
			setMessage(jsonObject.getString(MESSAGE));
			if (status == 0) {
				Log.e("", "General Message ： " + message);
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}

	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
}
